<template>
  <div class="new_common_app">
    <div class="new_common_app_title">{{ allocationObj.title }}</div>
    <template v-if="isHome">
      <div class="new_common_app_content">
        <el-carousel trigger="click" height="100px" :autoplay="false">
          <el-carousel-item v-for="(item, index) in carouselNum" :key="item">
            <div class="app_page">
              <template v-for="(o, i) in allocationObj.list">
                <div
                  class="app_item"
                  @click="goto(o)"
                  :key="i"
                  v-if="i < (index + 1) * 3 && i >= index * 3"
                >
                  <div class="item_left">
                    <img :src="o.img" alt="" />
                  </div>
                  <div class="item_right">
                    <p>访问 <i class="el-icon-right"></i></p>
                    <p>{{ o.name }}</p>
                  </div>
                </div>
              </template>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
    </template>
  </div>
</template>

<script>
export default {
  props: {
    allocationObj: { default: "" },
    isHome: { default: true },
  },
  data() {
    return {
      carouselNum: 0,
    };
  },
  created() {
    console.log("allocationObj", this.allocationObj);
    this.carouselNum = Math.ceil(this.allocationObj.list.length / 3);
    console.log("carouselNum", this.carouselNum);
  },
  methods: {
    goto(item) {
      window.open(item.urlAddress);
    },
  },
};
</script>

<style lang="scss" scoped>
.new_common_app {
  height: 100%;
  background-color: #fff;
  padding: 15px;
  border-radius: 8px;
  .new_common_app_title {
    font-family: "PingFang SC";
    font-weight: 400;
    font-size: 16px;
    color: #000000;
    line-height: 24px;
    padding: 0 10px;
  }
  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 50px;
    margin: 0;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: #ffffff;
  }

  .el-carousel__item:nth-child(2n + 1) {
    background-color: #ffffff;
  }
  >>> .el-carousel__button {
    background-color: #008dff !important;
  }
  .app_page {
    display: flex;
    flex: 1;
    justify-content: flex-start;
    margin-top: 10px;
  }
  .app_item:nth-child(1) {
    background: linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.62),
      rgba(233, 237, 252, 0.62)
    );
    border-radius: 8px;
    border: 1px solid #a3b9f9;
    margin-left: 10px;
  }
  .app_item:nth-child(2) {
    background: linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.62),
      rgba(253, 249, 225, 0.62)
    );
    border-radius: 8px;
    border: 1px solid #fbd58d;
    margin: 0 20px;
  }
  .app_item:nth-child(3) {
    background: linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.62),
      rgba(226, 254, 237, 0.62)
    );
    border-radius: 8px;
    margin-right: 10px;
    border: 1px solid #70daad;
  }
  .app_item {
    display: inline-block;
    width: 200px;
    height: 68px;
    border: 1px solid #008dff;
    padding: 7px 21px;
    cursor: pointer;
    .item_left {
      float: left;
      img {
        width: 45px;
        position: relative;
        top: 5px;
      }
    }
    .item_right {
      float: left;
      margin-left: 10px;
      p:nth-child(1) {
        font-size: 12px;
        color: #999999;
        line-height: 22px;
      }
      p:nth-child(2) {
        font-family: PingFangSC;
        font-weight: 400;
        font-size: 16px;
        color: #030303;
        line-height: 25px;
      }
    }
  }
}
>>> .el-carousel__button {
  width: 17px !important;
  height: 3px !important;
  border-radius: 2px !important;
}
</style>
